﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RPGNETContracts;

namespace RPGClient
{
    public class RPGNETRequest
    {
        RPGNETClient _client;

        public RPGNETRequest(RPGNETClient client)
        {
            _client = client;
        }

        public void Login(string machineId, string account, string password)
        {
            byte[] data = new byte[255];
            Array.Clear(data, 0, 255);
            int offset = 0;
            BufferUtil.ByteToBuffer(RPGNET_SCENARIO.INIT, data, offset, out offset);
            BufferUtil.ByteToBuffer(RPGNET_CLIENT_REQUEST.LOGIN, data, offset, out offset);
            BufferUtil.UShortToBuffer(0x01, data, offset, out offset);
            BufferUtil.UShortToBuffer(0x02, data, offset, out offset);
            BufferUtil.UShortToBuffer(0x03, data, offset, out offset);
            BufferUtil.StringToBuffer(machineId, data, offset, 64, out offset);
            BufferUtil.StringToBuffer(account, data, offset, 32, out offset);
            BufferUtil.StringToBuffer(password, data, offset, 32, out offset);

            _client.Send(data, offset);
        }
    }
}
